import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:osg/controllers/http.dart';



class Agreement extends StatefulWidget {

  Agreement({super.key});

  @override
  State<Agreement> createState() => _SettingPageState();
}

class _SettingPageState extends State<Agreement> {
  RxString info = ''.obs;
  RxString title = ''.obs;

  String? type = Get.parameters['type'];


getInfo(url){
  Get.find<HTTPS>()
        .getData('$url', {}).then((res) {
      if (res != null) {
        info.value = res['setting']['modules'][0]['html'];
        title.value = res['setting']['title'];
      }
    });
}


  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      if(type=='1'){
        getInfo('/setting/user_statement');
      }else if(type=='2'){
        getInfo('/setting/privacy_policy');

      }
      
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
           appBar: AppBar(
            backgroundColor: Color(0xffffffff),
            title:Obx(()=>
            Text('$title')
            )
             ,
            centerTitle: true
          ),
          body:ListView(
            children: [
  Obx(()=>
           Html(data: info.value,
           
            style: {
                
                "p": Style(
                  margin: Margins.only(top: 0,bottom: 0),
                  padding: HtmlPaddings.only(top: 0,bottom: 0),
                  lineHeight: LineHeight(1.0), // 调整行高
                ),
                "br": Style(
                  margin: Margins.only(top: 0,bottom: 0),
                  padding: HtmlPaddings.only(top: 0,bottom: 0),
                  height: Height(1), // 调整换行高度
                ),
              },),
           
          )
            ],
          )
        
    );
  }
}
